package com.shinetech.controller;

import com.google.common.base.Strings;
import com.shinetech.entity.User;
import com.shinetech.service.UserService;
import com.shinetech.vo.ObjectRestResponse;
import com.shinetech.vo.TableResultResponse;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by joy on 2017/7/8.
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController<User> {
    @Resource
    private UserService userService;




//    @PostMapping(value = "")
//    public ObjectRestResponse<User> addUser(User entity){
//        userService.saveUser(entity);
//        return new ObjectRestResponse<User>().rel(true);
//    }


    @RequestMapping(value = "/page",method = RequestMethod.GET)
    public TableResultResponse<User> page(@RequestParam(defaultValue = "10") int pagesize, @RequestParam(defaultValue = "0")int page, String name){
        List<User> user = userService.selectByName(pagesize,page,name);
        return new TableResultResponse<User>(user.size(),user);
    }



}
